#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#pragma unmanaged 
#include <ql\models\marketmodels\callability\nodedataprovider.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Models::Marketmodels;
#undef HANDLE
#define ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Models { namespace Marketmodels { namespace Callability {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IMarketModelNodeDataProvider
	public ref class CMarketModelNodeDataProvider : 
            public System::MarshalByRefObject,
            public Cephei::QL::Models::Marketmodels::Callability::IMarketModelNodeDataProvider
	{
	protected: 
		boost::shared_ptr<QuantLib::MarketModelNodeDataProvider>* _ppMarketModelNodeDataProvider;
        boost::detail::spinlock* _pSpinlock;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::MarketModelNodeDataProvider>* _phMarketModelNodeDataProvider;
#endif
		Object^ _MarketModelNodeDataProviderOwner;     // reference to object that manages the storage for this object
	internal:
        CMarketModelNodeDataProvider (boost::shared_ptr<QuantLib::MarketModelNodeDataProvider>& childNative, Object^ owner);
        CMarketModelNodeDataProvider (QuantLib::MarketModelNodeDataProvider& childNative, Object^ owner);
        CMarketModelNodeDataProvider (CMarketModelNodeDataProvider^ copy);
        CMarketModelNodeDataProvider (System::Type^ t);
#ifdef STRUCT
        CMarketModelNodeDataProvider (QuantLib::MarketModelNodeDataProvider childNative);
#endif       
#ifdef HANDLE
		CMarketModelNodeDataProvider (QuantLib::Handle<QuantLib::MarketModelNodeDataProvider>& childNative, Object^ owner);
		CMarketModelNodeDataProvider (QuantLib::Handle<QuantLib::MarketModelNodeDataProvider> childNative);
#endif
		virtual ~CMarketModelNodeDataProvider ();
		!CMarketModelNodeDataProvider ();

	internal:
		QuantLib::MarketModelNodeDataProvider& GetReference ();
		boost::shared_ptr<QuantLib::MarketModelNodeDataProvider>& GetShared ();
		QuantLib::MarketModelNodeDataProvider* GetPointer ();
        void SetMarketModelNodeDataProvider (boost::shared_ptr<QuantLib::MarketModelNodeDataProvider> native)
        {
            if (_ppMarketModelNodeDataProvider != NULL)
                delete _ppMarketModelNodeDataProvider;
            _ppMarketModelNodeDataProvider = new boost::shared_ptr<QuantLib::MarketModelNodeDataProvider> (native);
            
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::MarketModelNodeDataProvider>& GetHandle ();
#endif
		virtual bool HasNative () ;
		void Lock ()
		{
			if (Cephei::QL::Settings::_ReferenceLocking)
    			_pSpinlock->lock ();
		}
		void Unlock ()
		{
			_pSpinlock->unlock ();
		}
    public:
        property Cephei::QL::Models::Marketmodels::IEvolutionDescription^ Evolution 
        {
		    virtual Cephei::QL::Models::Marketmodels::IEvolutionDescription^ get () ;
        }
		virtual Cephei::QL::Models::Marketmodels::Callability::IMarketModelNodeDataProvider^ NextStep (Cephei::QL::Models::Marketmodels::ICurveState^ prm1) ;
        property Cephei::IVector<UInt64>^ NumberOfData 
        {
		    virtual Cephei::IVector<UInt64>^ get () ;
        }
        property UInt64 NumberOfExercises 
        {
		    virtual UInt64 get () ;
        }
        property Cephei::QL::Models::Marketmodels::Callability::IMarketModelNodeDataProvider^ Reset 
        {
		    virtual Cephei::QL::Models::Marketmodels::Callability::IMarketModelNodeDataProvider^ get () ;
        }
		virtual Cephei::QL::Models::Marketmodels::Callability::IMarketModelNodeDataProvider^ Values (Cephei::QL::Models::Marketmodels::ICurveState^ prm1, Cephei::IVector<Double>^ results) ;
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CMarketModelNodeDataProvider_Factory : public System::MarshalByRefObject,  public IMarketModelNodeDataProvider_Factory
	{
	public:
    };
   
/*Cephei*/ } /*QL*/ } /*Models*/ } /*Marketmodels*/ } /*Callability */}
